/**
 * TODO 用到的时候再重构此部分功能
 */
import { cacheApi } from '@/api/sys/common';
import { BasicColumn } from '@/components/Table';
import { FormSchema } from '@/components/Table';
import { useI18n } from '@/hooks/web/useI18n';
const { t } = useI18n();
export const columns: BasicColumn[] = [
  {
    title: t('数据源') + 'key',
    align: 'center',
    dataIndex: 'sourceCode',
  },
  {
    title: t('数据源名称'),
    align: 'center',
    dataIndex: 'sourceName',
  },
  {
    title: t('类型'),
    align: 'center',
    dataIndex: 'sourceType',
  },
  {
    title: t('类型'),
    align: 'center',
    dataIndex: 'sourceConfig',
  },
  {
    title: t('备注'),
    align: 'center',
    dataIndex: 'sourceDesc',
  },
];

export const searchFormSchema: FormSchema[] = [
  {
    field: 'sourceName',
    label: t('数据源名称'),
    component: 'Input',
    required: false,
  },
];

export const formSchema: FormSchema[] = [
  {
    field: 'id',
    label: '',
    component: 'Input',
    show: false,
  },
  {
    field: 'sourceCode',
    label: '数据源key',
    component: 'Input',
    required: true,
    colProps: {
      span: 12,
    },
  },
  {
    field: 'sourceName',
    label: t('数据源名称'),
    component: 'Input',
    required: true,
    colProps: {
      span: 12,
    },
  },
  {
    field: 'sourceType',
    label: t('数据源类型'),
    component: 'ApiSelect',
    componentProps: {
      dictCode: 'data_source_type',
    },
    required: true,
    colProps: {
      span: 12,
    },
  },
  {
    field: 'sourceConfig',
    label: t('数据源配置'),
    component: 'MonacoEditor',
    required: true,
    colProps: {
      span: 24,
    },
    componentProps: {
      language: 'json',
      autoFormat: true,
    },
  },
  {
    field: 'sourceDesc',
    label: t('备注'),
    component: 'InputTextArea',
  },
];
